var rrzf = {
    openRenren: function(event) {
        openUILinkIn( "http://www.renren.com/?origin=92009", "tab", true);
    }
}
window.addEventListener("load", function() {
    myExtension.init()
}, false);
//打开浏览器时执行 myExtension.init()
var myExtension = {
    init: function() {
        var appcontent = document.getElementById("appcontent");
        //appcontent是所有页面父节点的ID
        if (appcontent) appcontent.addEventListener("DOMContentLoaded", this.onPageLoad, true);
        //DOMContentLoaded事件触发myExtension.onPageLoad
    },

    onPageLoad: function(e) {
        var doc = e.originalTarget;
        
        // doc即网页中的document
        var scripts = doc.getElementsByTagName('script');
        var i = 0;
        //如果网页已经使用了人人forward 则不再添加人人forward
        for (i; i < scripts.length; i++) {
            if ('http://widget.renren.com/js/forward.js' == scripts[i].src) {
                return;
            }
        }
        var head = doc.getElementsByTagName('head')[0];
        //创建和配置config的script标签
        var config = doc.createElement('script');
        config.type = 'text/javascript';
        config.textContent = 'window.__fwdCfg = {"api_key" : "536942ba221549c89c7b3ead003cd5d1","img_minWidth": 200,"img_minHeight": 200,"text_minCount":15};';
        //创建和配置renren forward的script标签
        var renren = doc.createElement('script');
        renren.type = 'text/javascript';
        renren.src = "http://widget.renren.com/js/forward.js";
        renren.async = "true";
        //将两个js添加到head标签中间
        head.appendChild(config);
        head.appendChild(renren);
    }
}